<template>
  <div>
    <el-form inline size="mini">
      <el-form-item>
        <el-input v-model="title" clearable placeholder="合同标题"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button-group>
          <el-button type="primary" @click="query">查询</el-button>
          <el-button type="success" class="el-icon-plus" @click="openaddWindow"
            >新增</el-button
          >
        </el-button-group>
      </el-form-item>
    </el-form>
    <Ca-rule-table
      :DataList="contractList"
      :header="header"
      :headle="headle"
      @checkleave="checkitem"
    ></Ca-rule-table>
    <paging
      :currentpage="currentpage"
      :currentlimit="currentlimit"
      :total="15"
      @setpage="getpage"
      @setlimit="getlimit"
    ></paging>
    <el-dialog :visible.sync="isopen" :append-to-body="true">
      <qrcode-contract v-if="isopen" @close="close"></qrcode-contract>
    </el-dialog>
  </div>
</template>

<script>
import qrcodeContract from "./qrcode-contract";
import http from "@/request/http";
import QS from "qs";
import axios from "axios";
export default {
  data() {
    return {
      title: "",
      isopen: false,
      contractList: [],
      header: [
        ["编号", "construct_qrcode_id"],
        ["标题", "construct_qrcode_title"],
        ["内容", "construct_qrcode_content"]
      ],
      headle: ["查看"],
      currentpage: 1,
      currentlimit: 15
    };
  },

  components: {
    qrcodeContract
  },
  created() {
    this.getQrcodeList();
  },
  methods: {
    getlimit(e) {
      this.currentlimit = e;
      this.getQrcodeList();
    },
    getpage(e) {
      this.currentpage = e;
      this.getQrcodeList();
    },
    checkitem(row) {
      console.log(row);
      window.open(
        `${http.middle_url}qrcode_contract?construct_qrcode_id=${
          row.construct_qrcode_id
        }`
      );
    },
    close() {
      this.isopen = false;
    },
    query() {
      this.getQrcodeList();
    },
    openaddWindow() {
      this.isopen = true;
    },
    getQrcodeList() {
      let data = {
        title: this.title,
        page: this.currentpage,
        limit: this.currentlimit
      };
      axios
        .get(`${http.middle_url}queryConstructQr`, { params: data })
        .then(res => {
          this.contractList = res.data.data;
          console.log(res);
        });
    }
  }
};
</script>

<style lang="scss" scoped></style>
